#lang racket


(require "../config/main.rkt")

(require "constructor-defer.rkt"
         "constructor-imediate.rkt")

(provide render)


(define (render-impl node file dir ext width height)
  (begin0
    (evaluate node)
    (let ((path (format "~A~A.~A" (path->string dir) file ext)))
      (displayln (format "Render (~Ax~A) ~A" width height path))
      (render-shapes width height path))))

(define (render #:dir (dir (render-dir))
                #:ext (ext (render-ext))
                #:width (width (render-width))
                #:height (height (render-height))
                . args)
  (match args
    ((list node file)
     (render-impl node file dir ext width height))
    ((list node file center target)
     (render-impl (view center target node) file dir ext width height))
    ((list node file center target projection)
     (render-impl (view center target projection node) file dir ext width height))
    ((list node file center target projection lens)
     (render-impl (view center target projection lens node) file dir ext width height))))